﻿#pragma once

#include "../MirEnvir/Envir.h"
#include "../MessageQueue.h"
#include "../../Shared/Data/ItemData.h"
#include "../../Shared/Enums.h"
#include "../MirObjects/PlayerObject.h"
#include "../../Shared/Data/ClientData.h"
#include <string>
#include <vector>
#include <algorithm>
#include <optional>
#include "../../stringhelper.h"
#include "../../tangible_filesystem.h"

using namespace Server::MirEnvir;
using namespace Server::MirObjects;

namespace Server::MirDatabase
{
    class RecipeInfo
    {
    public:
        virtual ~RecipeInfo()
        {
            delete Item;
        }

    protected:
        static Server::MirEnvir::Envir *getEnvir();

        static Server::MessageQueue *getMessageQueue();

    public:
        UserItem *Item;
        std::vector<UserItem*> Ingredients;
        std::vector<UserItem*> Tools;

        std::vector<int> RequiredFlag = std::vector<int>();
        std::optional<unsigned short> RequiredLevel;
        std::vector<int> RequiredQuest = std::vector<int>();
        std::vector<MirClass> RequiredClass = std::vector<MirClass>();
        std::optional<MirGender> RequiredGender;

        unsigned char Chance = 100;
        unsigned int Gold = 0;

        RecipeInfo(const std::string &name);

    private:
        void LoadIngredients(const std::string &recipe);

    public:
        bool MatchItem(int index);

        bool CanCraft(PlayerObject *player);

        ClientRecipeInfo *CreateClientRecipeInfo();
    };
}


